package com.ainge.easystudy.sort;

/**
 * @author: Ainge
 * @Time: 2021/9/16 00:34
 */
public class GetMax {

    public static void main(String[] args) {
        int[] arr = new int[]{1, 24, 3, 4, 5, 6, 7, 33, 8, 9, 999, 999};
        System.out.println(getMax(arr));
    }


    public static int getMax(int[] array) {
        return process(array, 0, array.length - 1);
    }

    private static int process(int[] array, int left, int right) {
        if (left == right) {
            return array[left];
        }
        // 取中点index
        int mid = left + ((right - left) >> 1);
        int leftMax = process(array, left, mid);
        int rightMax = process(array, mid + 1, right);
        return Math.max(leftMax, rightMax);
    }

}
